var pageSize = 6;
var pageNum = 1;
var totalPages = 1;


function queryList() {
	var param = getQueryParam();
	$.loading.start();
	$.ajax({
		url: "http://" + remote_ip + ":" + remote_port +"/"+remote_name+ "/app/screen/show/listLocal", //路径 
		dataType: "json",
		data: param,
		type: 'POST',
		success: function(result) { //返回数据根据结果进行相应的处理  
            console.log(result);
			var data = result.rows;
			totalPages = Math.ceil(result.total / pageSize);
			drawList(data);
			if(result.total == 0) {
				$(".tablelist-append").html("<div class='no-data-div'><div class='no-data-img' style='text-align:center'><img src='../images/bg_empty_data.png'></div><dl><dt>暂无记录</dt></dl></div>");
			}
			$.loading.stop();
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {

		}
	});

}

function getQueryParam() {
	var param = new Object();
	param.pageSize = pageSize;
	param.pageNo = pageNum;

	if($("#bank").val() != "") {
		param.name = $("#bank").val();
    }
    if($("#officeId").val() != "") {
		param.officeId = $("#officeId").val();
	}
	
	return param;
}

function drawList(data) {

	//$(".tablelist-append").html("");
	var strHtml = "";
	
	for(var i = 0; i < data.length; i++) {
		var id = data[i].id;
		var name = data[i].name;
		var officename = "";
		if(data[i].office!=undefined){
			officename=data[i].office.name==undefined?"":data[i].office.name;
		}
		var curl="deviceData.html?id="+id;

		strHtml += "<div class='product single_item info' curl='"+curl+"'>";
	
		strHtml += "<li><div class='item'>";
		strHtml += "<dl><dt><a href='javascript:void(0)' data-scroll='1' class='GO-GOODS-INFO'>" + name + "</a></dt>";
        strHtml += "<a class='shop-name' href='#'>"+officename+"</a>";
        strHtml += "<dd><i class='price-color'>数据正常</i></dd>";
		strHtml += "<div class='item-con-info'>";
		strHtml += "<span class='goods-sales'></span>";
		strHtml += "<div class='cart-box bill-show' >查看</div>";
		strHtml += "</div></dl></div></li></div>";
	}
	$(".tablelist-append").append(strHtml);
	
	$(".single_item").click(function(){
		window.location.href=$(this).attr("curl");
	});
	
}
